import request from '@/router/axios';

export const getEquipmentList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=MACHINE',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getFeederList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=PRINTER',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getFeederCarList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=PRINTER',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getSteelMeshList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=PRINTER',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
export const getScraperList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=PRINTER',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
export const getScraperListCutter = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?type=PRINTER',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/ems-equipment/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/ems-equipment/remove',
    method: 'post',
    data: ids
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/ems-equipment/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/ems-equipment/submit',
    method: 'post',
    data: row
  });
};

// 变更设备状态记录
export const changeStateRecord = (data) => {
  return request({
    url: '/api/mes-product/ems-equipment/change-state-record',
    method: 'post',
    data
  });
};

// 根据设备编码获取设备变更记录
export const changeStateRecordDetail = (equipmentNo) => {
  return request({
    url: '/api/mes-product/ems-equipment/change-state-record-detail',
    method: 'get',
    params: {
      equipmentNo
    }
  });
};

// 分页查询设备变更记录
export const changeRecordPage = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page-change-records',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

//工具事务记录
export const getToolUsage = (current, size, params) => {
  return request({
    url: '/api/mes-product/tool/usage/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const equipmentEnable = (id) => {
  return request({
    url: '/api/mes-product/ems-equipment/enable',
    method: 'post',
    params: {
      id
    }
  });
};
export const equipmentDisable = (id) => {
  return request({
    url: '/api/mes-product/ems-equipment/disable',
    method: 'post',
    params: {
      id
    }
  });
};

export const getTestRackList = (current, size, params) => {
  return request({
    url: '/api/mes-product/ems-equipment/page?categoryCode=TEST_RACK',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
